//
//  LZ_MainTableViewCell.m
//  LzzizDemo
//
//  Created by xbnzd on 16/10/25.
//  Copyright © 2016年 xbnzd. All rights reserved.
//

#import "LZVideoTableViewCell.h"
#import "GiftListLabel.h"
#import "Masonry.h"
#import "LZTimeLimitCountDownJudgeDataManager.h"
#import "XBNTimeLimitCountDownCalculator.h"
#import "HCSStarRatingView.h"
#import "UIImageView+WebCache.h"
#import "LZLanguageManager.h"

static CGFloat kStarBgViewWidth = 80.0;
static CGFloat kStarBgViewHeiht = 12.0;
static CGFloat kCellBtnsViewHeight = 21.0;
static CGFloat kTopGrayViewHegith = 49.0;
static CGFloat kCouponAngGrouponViewHeight = 54.0;

@interface LZVideoTableViewCell()

@property (nonatomic, strong) UIView      *topGrayBgView;        //顶部灰色底图
@property (nonatomic, strong) UIImageView *userIcon;             //头像
@property (nonatomic, strong) UILabel     *userNameLabel;        //姓名
@property (nonatomic, strong) UILabel     *timeLabel;            //时间
@property (nonatomic, strong) UILabel     *viewsCountLabel;      //浏览次数
@property (nonatomic, strong) UIImageView *viewsIcon;            //浏览icon
@property (nonatomic, strong) UIImageView *videoCoverImg;         //视频封面图片
@property (nonatomic, strong) UIView      *couponsAndGrouponBgView;        //优惠券底图
@property (nonatomic, strong) UIView      *couponsAndGrouponTopLine;    //横线
@property (nonatomic, strong) UIView      *couponsAndGrouponMidLine;    //中间竖线
@property (nonatomic, strong) UIView      *couponsBgView;        //优惠券底图
@property (nonatomic, strong) UIImageView *couponsIcon;          //优惠券图标
@property (nonatomic, strong) UILabel     *couponsTitleLabel;    //优惠券title
@property (nonatomic, strong) UILabel     *couponsCountLabel;    //优惠券剩余数量
@property (nonatomic, assign) CGFloat      couponsTextHeight;    //优惠券文本高度
@property (nonatomic, strong) UIView      *groupsBgView;         //团购底图
@property (nonatomic, strong) UIImageView *groupsIcon;           //团购图标
@property (nonatomic, strong) UILabel     *groupsTitleLabel;     //团购title
@property (nonatomic, strong) UILabel     *groupsCountdownLabel; //团购倒计时
@property (nonatomic, assign) CGFloat      groupsTextHeight;     //团购文本高度
@property (nonatomic, strong) GiftListLabel     *descLabel;            //描述
@property (nonatomic, strong) UIView      *starBgView;           //星星评价底图
@property (nonatomic, strong) UIView      *footBtnsBgView;       //底部按钮底图
@property (nonatomic, strong) UIImageView *moreImgView;          //更多图片
@property (nonatomic, strong) UIButton    *moreBtn;              //更多按钮
@property (nonatomic, strong) UIImageView *zanImg;               //赞图片
@property (nonatomic, strong) UILabel     *zanCountLabel;        //赞的数量
@property (nonatomic, strong) UIButton    *zanBtn;               //点赞按钮
@property (nonatomic, strong) UIImageView *collectImg;           //收藏图片
@property (nonatomic, strong) UILabel     *collectCountLabel;    //收藏的数量
@property (nonatomic, strong) UIButton    *collectBtn;           //收藏按钮
@property (nonatomic, strong) UIImageView *msgImg;               //信息图片
@property (nonatomic, strong) UILabel     *msgCountLabel;        //信息的数量
@property (nonatomic, strong) UIButton    *msgBtn;               //信息的按钮
@property (nonatomic, strong) UIImageView *shareImg;             //分享图片
@property (nonatomic, strong) UILabel     *shareCountLabel;      //分享的数量
@property (nonatomic, strong) UIButton    *shareBtn;             //分享按钮
@property (nonatomic, strong) UIImageView *collectOrEditImgView; //右上角收藏或者编辑按钮
@property (nonatomic, strong) UIButton    *collectOrEditBtn;     //右上角收藏或者编辑按钮
@property (nonatomic, strong) NSIndexPath *indexP;               //标记indexpath
@property (nonatomic, strong) HCSStarRatingView *starRatingView; //创建星星
@property (nonatomic, strong) UIView            *footGrayView;    //底部色条

//===由于某些地方不需要展示相关空间,这里标记是否隐藏,隐藏的话降不在赋值
@property (nonatomic, assign) BOOL showHeadView;  //标记是否展示了顶部的View
@property (nonatomic, assign) BOOL showBtnsView;  //标记是否展示按钮的View
@property (nonatomic, assign) BOOL showCouponAndGroupsView; //标记是否需要展示抢券和拼团的View


@end

@implementation LZVideoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        //灰色顶部
        [self.contentView addSubview:self.topGrayBgView];
        [self.topGrayBgView addSubview:self.userIcon];
        [self.topGrayBgView addSubview:self.userNameLabel];
        [self.topGrayBgView addSubview:self.timeLabel];
        [self.topGrayBgView addSubview:self.viewsIcon];
        [self.topGrayBgView addSubview:self.viewsCountLabel];
        
        //视频底图
        [self.contentView addSubview:self.playerBgView];
        //视频封面
        [self.playerBgView addSubview:self.videoCoverImg];
        
        //右上角按钮和图片
        [self.contentView addSubview:self.collectOrEditImgView];
        [self.contentView addSubview:self.collectOrEditBtn];
        
        //底部按钮
        [self.contentView addSubview:self.footBtnsBgView];
        [self.footBtnsBgView addSubview:self.zanImg];
        [self.footBtnsBgView addSubview:self.zanCountLabel];
        [self.footBtnsBgView addSubview:self.zanBtn];
        
        [self.footBtnsBgView addSubview:self.collectImg];
        [self.footBtnsBgView addSubview:self.collectCountLabel];
        [self.footBtnsBgView addSubview:self.collectBtn];
        
        [self.footBtnsBgView addSubview:self.msgImg];
        [self.footBtnsBgView addSubview:self.msgCountLabel];
        [self.footBtnsBgView addSubview:self.msgBtn];
        
        [self.footBtnsBgView addSubview:self.shareImg];
        [self.footBtnsBgView addSubview:self.shareCountLabel];
        [self.footBtnsBgView addSubview:self.shareBtn];
        
        //简介
        [self.contentView addSubview:self.descLabel];
        
        //星评底图
        [self.contentView addSubview:self.starBgView];
        
        //更多
        [self.contentView addSubview:self.moreImgView];
        [self.contentView addSubview:self.moreBtn];
        
        //优惠券,拼团
        [self.contentView addSubview:self.couponsAndGrouponBgView];
        [self.couponsAndGrouponBgView addSubview:self.couponsAndGrouponTopLine];
        [self.couponsAndGrouponBgView addSubview:self.couponsAndGrouponMidLine];
        [self.couponsAndGrouponBgView addSubview:self.couponsBgView];
        [self.couponsBgView addSubview:self.couponsIcon];
        [self.couponsBgView addSubview:self.couponsTitleLabel];
        [self.couponsBgView addSubview:self.couponsCountLabel];
        [self.couponsAndGrouponBgView addSubview:self.groupsBgView];
        [self.groupsBgView addSubview:self.groupsIcon];
        [self.groupsBgView addSubview:self.groupsTitleLabel];
        [self.groupsBgView addSubview:self.groupsCountdownLabel];
        
        //底部灰色条
        [self.contentView addSubview:self.footGrayView];
        
    }
    
    [self initUI];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(goToRestaurantDetailAction)];
    self.topGrayBgView.userInteractionEnabled = YES;
    [self.topGrayBgView addGestureRecognizer:tap];
    
    self.descLabel.preferredMaxLayoutWidth = SCREEN_WIDTH - 115;
    
    return self;
}

- (void)drawRect:(CGRect)rect {
    [super drawRect:rect];
    // 设置头像圆角
    self.userIcon.layer.masksToBounds = YES;
    self.userIcon.layer.cornerRadius = CGRectGetHeight(self.userIcon.bounds)/2.0;
}

/*
+ (CGFloat)getCellHeightWithModel:(LZVideoListModel *)m withShowHeadView:(BOOL)showHead showCellBtns:(BOOL)showCellBtns showCouponAndGroupsView:(BOOL)showcouponView
{
    GET_SCREEN_SCALE(scale);
    CGFloat headViewHeight = kTopGrayViewHegith*scale;
    CGFloat cellBtnsHeight = kCellBtnsViewHeight*scale;
    CGFloat couponAndGroupViewHegith = kCouponAngGrouponViewHeight*scale;
    
    if (!showHead) {
        headViewHeight = 0;
    }
    
    if (!showCellBtns) {
        cellBtnsHeight = 0;
    }
    
    if (!showcouponView) {
        couponAndGroupViewHegith = 0;
    }else{
      if(m.couponsName.length == 0 && m.grouponName.length == 0){//优惠券,团购都没有
          couponAndGroupViewHegith = 0;
        }
    }
    
    CGFloat textHeight = [self getTextHeight:m.promotionTitle];
    
    CGFloat cellHeight = headViewHeight + SCREEN_WIDTH + couponAndGroupViewHegith + 9 + textHeight + 10 + cellBtnsHeight + 12 + 1;
    return cellHeight;
}

//赞未用
+ (CGFloat)getTextHeight:(NSString *)text
{
    if (text.length == 0) {
        return  21;
    }
    extern CGFloat textLineSpace;
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    [style setLineSpacing:textLineSpace];
    [style setLineBreakMode:NSLineBreakByCharWrapping];
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:15], NSParagraphStyleAttributeName:style};
    CGSize size = [text boundingRectWithSize:CGSizeMake(SCREEN_WIDTH - 35 - kStarBgViewWidth, 100) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
    
    if (size.height < 30) {
        return 21;
    }
    
    return 46;
}
*/

#pragma mark -
#pragma mark 赋值方法
- (void)loadDataWithIndex:(NSIndexPath *)index WithShowHeadView:(BOOL)showHead showCellBtns:(BOOL)showCellBtns showCouponAndGroupsView:(BOOL)showcouponView
{
    _showHeadView = showHead;
    _showBtnsView = showCellBtns;
    _showCouponAndGroupsView = showcouponView;
    _indexP = index;
    
    if (!showHead) {
        [self hiddenHeadView];
    }
    
    if (!showCellBtns) {
        [self hiddenCellBtnsView];
    }
    
    if (!showcouponView) {
        [self hidddenCouponAndGroupsView];
    }
    
}

- (void)startTimeDown
{
    if (self.timeCountDownCalculator == nil) {
        self.timeCountDownCalculator = [XBNTimeLimitCountDownCalculator new];
    }
    self.timeCountDownCalculator.remainTimeInterval = self.model.grouponEndTime/1000 - self.model.currentTime;
    
    if (self.timeCountDownCalculator.remainTimeInterval<=0) {
        [LZTimeLimitCountDownJudgeDataManager configLimitedLabel:self.groupsCountdownLabel withReamin:0 andDayUnit:@"D " HourUnit:@"H " andMinuteUnit:@"M " andSecUnit:@"S " andIsChangeUintColor:YES andDayUnitColor:UIColorFromRGB(0xff7a21, 1) HourUnitColor:UIColorFromRGB(0xff7a21, 1) andMinUnitColor:UIColorFromRGB(0xff7a21, 1) andSecUnitColor:UIColorFromRGB(0xff7a21, 1)];
        [self.timeCountDownCalculator timeLimitCountDownClear];
    }
    else {
        WS(weakSelf);
        
        [self.timeCountDownCalculator addProcessBlock:^(NSTimeInterval remain) {
            //        DLog(@"计时进行中 %f",remain);
            if (remain<0) {
                [LZTimeLimitCountDownJudgeDataManager configLimitedLabel:weakSelf.groupsCountdownLabel withReamin:0 andDayUnit:@"D " HourUnit:@"H " andMinuteUnit:@"M " andSecUnit:@"S " andIsChangeUintColor:YES andDayUnitColor:UIColorFromRGB(0xff7a21, 1) HourUnitColor:UIColorFromRGB(0xff7a21, 1) andMinUnitColor:UIColorFromRGB(0xff7a21, 1) andSecUnitColor:UIColorFromRGB(0xff7a21, 1)];
                [weakSelf.timeCountDownCalculator timeLimitCountDownClear];
            }
            else {
                [LZTimeLimitCountDownJudgeDataManager configLimitedLabel:weakSelf.groupsCountdownLabel withReamin:remain andDayUnit:@"D " HourUnit:@"H " andMinuteUnit:@"M " andSecUnit:@"S " andIsChangeUintColor:YES andDayUnitColor:UIColorFromRGB(0xff7a21, 1) HourUnitColor:UIColorFromRGB(0xff7a21, 1) andMinUnitColor:UIColorFromRGB(0xff7a21, 1) andSecUnitColor:UIColorFromRGB(0xff7a21, 1)];
            }
            
        } cancelBlock:^{
            //        DLog(@"结束了");
        }];
        
        [self.timeCountDownCalculator timeLimitCountDownResume];
    }
    
    [self changeGroupTitleLabelAndTimeDownLabelMasonry];
}


/**
 返回 浏览次数label 在外侧赋值

 @return label
 */
- (UILabel *)getViewsCountLabel
{
    return self.viewsCountLabel;
}


#pragma mark -
#pragma mark private
- (void)setVcType:(MyRecordsType)vcType {
    _vcType = vcType;
    if (vcType == MyRecordsType_ToBeReviewed) {
        // 我的待评价
        self.collectOrEditBtn.tag = 7;
        [self setCollectOrEditNormalImage:[UIImage imageNamed:@"待点评_按钮"] andHighLightedImage:[UIImage imageNamed:@"待点评_按钮"]];
    } else if (vcType == MyRecordsType_Favorites) {
        // 我的收藏
        self.collectOrEditBtn.tag = 8;
        [self setCollectOrEditNormalImage:[UIImage imageNamed:@"我的_视频收藏"] andHighLightedImage:[UIImage imageNamed:@"我的_视频已收藏"]];
    }
}

- (void)setModel:(LZVideoListModel *)model
{
    _model = model;

    //设置顶部数据
    if (_showHeadView) {
        [self.userIcon sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",APIBaseImageUrl,model.sellerPhoto]] placeholderImage:[UIImage imageNamed:@"未设置头像"]];
        self.userNameLabel.text = model.restaurantName;
        self.timeLabel.text = model.publishTime;
        self.viewsCountLabel.text = [NSString stringWithFormat:@"%ld",(long)model.playCount];
    }
    
    //视频海报
    [self.videoCoverImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",APIBaseImageUrl,model.videoPhoto]] placeholderImage:[UIImage imageNamed:@"videoCoverImg"]];
    
    //设置按钮视图数据
    if (_showBtnsView) {
        self.zanCountLabel.text = [NSString stringWithFormat:@"%ld",(long)model.likesCount];
        self.collectCountLabel.text = [NSString stringWithFormat:@"%ld",(long)model.storeCount];
        self.msgCountLabel.text = [NSString stringWithFormat:@"%ld",(long)model.remarkCountPerson];
        self.shareCountLabel.text = [NSString stringWithFormat:@"%ld",(long)model.shareCount];
        
        self.zanImg.highlighted = model.isLiked ? YES : NO;
        self.zanBtn.enabled = model.isLiked ? NO : YES;
        self.collectImg.highlighted = model.isStore;
        
    }
    
    self.collectOrEditImgView.highlighted = model.isStore;

    
    //描述数据
    if (model.promotionTitle.length > 0) {
        [self setDescLabelText:model.promotionTitle];
        
    }else{
        self.descLabel.text = @" ";

    }

    //星星级别
    [self setStarViewWithLevel:model.starLevel];
    
    //设置抢券,拼团数据
    if (_showCouponAndGroupsView) {
        if (model.couponsName.length > 0 && model.grouponName.length > 0) {//两者都有
            
            self.couponsTitleLabel.text = LZLocalizedString(@"get_coupon_big", nil);
            self.couponsCountLabel.text = [NSString stringWithFormat:@"%@ %@",LZLocalizedString(@"group_left_big", nil),model.couponsResidueCount];
            self.groupsTitleLabel.text = LZLocalizedString(@"group_order_big", nil);
            [self restoreCouponAndGroupView];
            
        }else if(model.couponsName.length == 0 && model.grouponName.length == 0){//优惠券,团购都没有
            [self hidddenCouponAndGroupsView];
        }else if (model.couponsName.length > 0 && model.grouponName.length == 0){//只有优惠券
            
            self.couponsTitleLabel.text = LZLocalizedString(@"get_coupon_big", nil);
            self.couponsCountLabel.text = [NSString stringWithFormat:@"%@ %@",LZLocalizedString(@"group_left_big", nil),model.couponsResidueCount];
            [self onlyHaveCoupon];
            
        }else if (model.couponsName.length == 0 && model.grouponName.length > 0){//只有团购
            
            self.groupsTitleLabel.text = LZLocalizedString(@"group_order_big", nil);
            [self onlyHaveGroup];
        }
        
    }

}


/**
 设置右上角按钮图片

 @param img <#img description#>
 */
- (void)setCollectOrEditNormalImage:(UIImage *)img andHighLightedImage:(UIImage*)highLightedImage
{
    self.collectOrEditBtn.hidden = NO;
    self.collectOrEditImgView.hidden = NO;
    self.collectOrEditImgView.image = img;
    self.collectOrEditImgView.highlightedImage = highLightedImage;
}

- (void)refreshZanView
{
    self.zanCountLabel.text = [NSString stringWithFormat:@"%ld",(long)_model.likesCount];
    self.zanBtn.enabled = _model.isLiked ? NO : YES;
    self.zanImg.highlighted = _model.isLiked ? YES : NO;
}

- (void)refreshCollectView
{
    self.collectImg.highlighted = _model.isStore;
    self.collectCountLabel.text = [NSString stringWithFormat:@"%ld",(long)_model.storeCount];
    self.collectOrEditImgView.highlighted = _model.isStore;
    
}

- (void)refreshReviewView {
    self.msgCountLabel.text = [NSString stringWithFormat:@"%ld",(long)_model.remarkCountPerson];
}

- (void)refreshShareView
{
    self.shareCountLabel.text = [NSString stringWithFormat:@"%ld",(long)_model.shareCount];
}

- (void)refreshAllCount
{
    self.zanCountLabel.text = [NSString stringWithFormat:@"%ld",(long)_model.likesCount];
    self.collectCountLabel.text = [NSString stringWithFormat:@"%ld",(long)_model.storeCount];
    [self refreshReviewView];
    [self refreshShareView];
}

#pragma mark -
#pragma mark private
/**
 *  @author Zhoudan, 16-10-25 19:10:09
 *
 *  描述
 *
 */
- (void)setDescLabelText:(NSString *)text
{
    if (text.length == 0) {
        return;
    }
    extern CGFloat textLineSpace;
    NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:text];
    NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
    [style setLineSpacing:textLineSpace];
    [style setLineBreakMode:NSLineBreakByCharWrapping];
    [attStr addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, text.length)];
    self.descLabel.attributedText = attStr;
    
}

/**
 *  @author Zhoudan, 16-10-25 19:10:25
 *
 *  布局星星
 *
 *  @param index level 值
 */
- (void)setStarViewWithLevel:(CGFloat)index
{
    self.starRatingView.value = index;

}

- (CGFloat)couponsTextHeight
{
    GET_SCREEN_SCALE(scale)
    if (_couponsTextHeight < 10) {
        CGSize size = [LZLocalizedString(@"get_coupon_big", nil) boundingRectWithSize:CGSizeMake(200, 100) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont fontWithName:@"Arial-BoldMT" size:12*scale]} context:nil].size;
        CGSize sizeCount = [@"DDDDD" boundingRectWithSize:CGSizeMake(200, 100) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont fontWithName:@"ArialMT" size:12*scale]} context:nil].size;
        
        _couponsTextHeight = size.height + 5 +sizeCount.height;
        
        return _couponsTextHeight;
    }
    
    return _couponsTextHeight;
}

- (CGFloat)groupsTextHeight
{
    GET_SCREEN_SCALE(scale)
    if (_groupsTextHeight < 10) {
        CGSize size = [LZLocalizedString(@"group_order_big", nil) boundingRectWithSize:CGSizeMake(200, 100) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont fontWithName:@"Arial-BoldMT" size:12*scale]} context:nil].size;
        CGSize sizeCount = [@"DDDDD" boundingRectWithSize:CGSizeMake(200, 100) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont fontWithName:@"ArialMT" size:12*scale]} context:nil].size;
        
        _groupsTextHeight = size.height + 5 +sizeCount.height;
        
        return _groupsTextHeight;
    }
    
    return _groupsTextHeight;
}

- (void)changeGroupTitleLabelAndTimeDownLabelMasonry
{
    CGFloat titleW = [self.groupsTitleLabel intrinsicContentSize].width;
    CGFloat timeLabelW = [self.groupsCountdownLabel intrinsicContentSize].width;
    if (timeLabelW > titleW) {
        //拼团名称
        [self.groupsTitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.groupsBgView).offset(self.couponsTextHeight/2 - 5);
            make.leading.equalTo(self.groupsCountdownLabel);
        }];
        
        //拼团icon
        [self.groupsIcon mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.couponsBgView);
            make.trailing.equalTo(self.groupsCountdownLabel.mas_leading).offset(-10);
        }];
        
        //拼团倒计时
        [self.groupsCountdownLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.groupsTitleLabel.mas_bottom).offset(3);
            
            if ([[LZLanguageManager shareInstance] getLanguageType] == LanguageType_Ar) {
                make.centerX.equalTo(self.groupsBgView).offset(-15);
            }else{
                make.centerX.equalTo(self.groupsBgView).offset(15);
            }
        }];
        

    }else{
        //拼团名称
        [self.groupsTitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.groupsBgView).offset(self.couponsTextHeight/2 - 5);
            if ([[LZLanguageManager shareInstance] getLanguageType] == LanguageType_Ar) {
                make.centerX.equalTo(self.groupsBgView).offset(-15);
            }else{
                make.centerX.equalTo(self.groupsBgView).offset(15);
            }
        }];
        
        //拼团icon
        [self.groupsIcon mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.couponsBgView);
            make.trailing.equalTo(self.groupsTitleLabel.mas_leading).offset(-10);
        }];
        
        //拼团倒计时
        [self.groupsCountdownLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.groupsTitleLabel.mas_bottom).offset(3);
            make.leading.equalTo(self.groupsTitleLabel);
        }];
    }
    
}
#pragma mark -
#pragma mark btn  action

/**
 点击进入餐厅详情==
 */
- (void)goToRestaurantDetailAction
{
    if (self.cellClickDelegate && [self.cellClickDelegate respondsToSelector:@selector(clickCellButtonWithIndex:andCellIndexPath:andModel:andOtherObject:refreshBlock:)]) {
        [self.cellClickDelegate clickCellButtonWithIndex:kVideoCellDelegate_restaurantDetailEvent andCellIndexPath:_indexP andModel:self.model andOtherObject:nil refreshBlock:^(VideoCellRefreshType type, BOOL isRefresh) {
           
        }];
    }
}

/**
 *  @author Zhoudan, 16-10-27 15:10:28
 *
 *  点击视频封面,播放视频
 */
- (void)playAction
{
    if (self.mainDelegate && [self.mainDelegate respondsToSelector:@selector(playVideoWhenClickVideoCoverImgWithIndex:)]) {
        [self.mainDelegate performSelector:@selector(playVideoWhenClickVideoCoverImgWithIndex:) withObject:_indexP];
    }
}

/**
 点赞
 */
- (void)zanBtnAction
{
    if (self.cellClickDelegate && [self.cellClickDelegate respondsToSelector:@selector(clickCellButtonWithIndex:andCellIndexPath:andModel:andOtherObject:refreshBlock:)]) {
        WS(weakSelf)
        [self.cellClickDelegate clickCellButtonWithIndex:kVideoCellDelegate_zanEvent andCellIndexPath:_indexP andModel:self.model andOtherObject:nil refreshBlock:^(VideoCellRefreshType type, BOOL isRefresh) {
            if (type == VideoCellRefreshType_Zan && isRefresh) {
                [weakSelf refreshZanView];
            }
        }];
    }
}

/**
 收藏
 */
- (void)collectBtnAction
{
    if (self.cellClickDelegate && [self.cellClickDelegate respondsToSelector:@selector(clickCellButtonWithIndex:andCellIndexPath:andModel:andOtherObject:refreshBlock:)]) {
        WS(weakSelf)
        [self.cellClickDelegate clickCellButtonWithIndex:kVideoCellDelegate_collectEvent andCellIndexPath:_indexP andModel:self.model andOtherObject:nil refreshBlock:^(VideoCellRefreshType type, BOOL isRefresh) {
            if (type == VideoCellRefreshType_Collect && isRefresh) {
                [weakSelf refreshCollectView];
            }
        }];
    }
}

/**
 评价
 */
- (void)msgBtnAction
{
    if (self.cellClickDelegate && [self.cellClickDelegate respondsToSelector:@selector(clickCellButtonWithIndex:andCellIndexPath:andModel:andOtherObject:refreshBlock:)]) {
        WS(weakSelf)
        [self.cellClickDelegate clickCellButtonWithIndex:kVideoCellDelegate_commentEvent andCellIndexPath:_indexP andModel:self.model andOtherObject:nil refreshBlock:^(VideoCellRefreshType type, BOOL isRefresh) {
            if (type == VideoCellRefreshType_Review && isRefresh) {
                [weakSelf refreshReviewView];
            }
        }];
    }
}

/**
 分享
 */
- (void)shareBtnAction
{
    if (self.cellClickDelegate && [self.cellClickDelegate respondsToSelector:@selector(clickCellButtonWithIndex:andCellIndexPath:andModel:andOtherObject:refreshBlock:)]) {
        WS(wSelf);
        [self.cellClickDelegate clickCellButtonWithIndex:kVideoCellDelegate_shareEvent andCellIndexPath:_indexP andModel:self.model andOtherObject:nil refreshBlock:^(VideoCellRefreshType type, BOOL isRefresh) {
            if (type == VideoCellRefreshType_Share && isRefresh) {
                [wSelf refreshShareView];
            }
        }];
    }
}

/**
 详情
 */
- (void)showMoreAction
{
    if (self.cellClickDelegate && [self.cellClickDelegate respondsToSelector:@selector(clickCellButtonWithIndex:andCellIndexPath:andModel:andOtherObject:refreshBlock:)]) {
        WS(weakSelf)
        [self.cellClickDelegate clickCellButtonWithIndex:kVideoCellDelegate_goDetailEvent andCellIndexPath:_indexP andModel:self.model andOtherObject:self.timeCountDownCalculator refreshBlock:^(VideoCellRefreshType type, BOOL isRefresh) {
            if (isRefresh) {
                if (type == VideoCellRefreshType_Zan) {
                    [weakSelf refreshZanView];
                }
                else if (type == VideoCellRefreshType_Collect) {
                    [weakSelf refreshCollectView];
                }
                else if (type == VideoCellRefreshType_AllCount){
                    
                }
            }
            
        }];
    }
}

/**
 优惠券详情
 */
- (void)couponsDetailAction
{
    WS(wSelf);
    if (self.cellClickDelegate && [self.cellClickDelegate respondsToSelector:@selector(clickCellButtonWithIndex:andCellIndexPath:andModel:andOtherObject:refreshBlock:)]) {
        [self.cellClickDelegate clickCellButtonWithIndex:kVideoCellDelegate_goCouponEvent andCellIndexPath:_indexP andModel:self.model andOtherObject:nil refreshBlock:^(VideoCellRefreshType type, BOOL isRefresh) {
            if (type == VideoCellRefreshType_Coupon && isRefresh) {
                wSelf.couponsCountLabel.text = [NSString stringWithFormat:@"%@ %@",LZLocalizedString(@"group_left_big", nil),wSelf.model.couponsResidueCount];
            }
        }];
    }
}

/**
 团购详情
 */
- (void)groupsDetailAction
{
    if (self.cellClickDelegate && [self.cellClickDelegate respondsToSelector:@selector(clickCellButtonWithIndex:andCellIndexPath:andModel:andOtherObject:refreshBlock:)]) {
        [self.cellClickDelegate clickCellButtonWithIndex:kVideoCellDelegate_goGroupEvent andCellIndexPath:_indexP andModel:self.model andOtherObject:self.timeCountDownCalculator refreshBlock:^(VideoCellRefreshType type, BOOL isRefresh) {
        }];
    }
}

/**
 右上角收藏或者编辑按钮,只针对部分页面
 */
- (void)collectOrEditBtnAction:(UIButton*)sender
{
    if (self.cellClickDelegate && [self.cellClickDelegate respondsToSelector:@selector(clickCellButtonWithIndex:andCellIndexPath:andModel:andOtherObject:refreshBlock:)]) {
        WS(weakSelf)
        VideoCellDelegateClickEventCode index = kVideoCellDelegate_topRightCornerCommentEvent;
        if (self.vcType == MyRecordsType_ToBeReviewed) {
            index = kVideoCellDelegate_topRightCornerCommentEvent;
        } else if (self.vcType == MyRecordsType_Favorites) {
            index = kVideoCellDelegate_topRightCornerCollectEvent;
        }
        
        [self.cellClickDelegate clickCellButtonWithIndex:index andCellIndexPath:_indexP andModel:self.model andOtherObject:nil refreshBlock:^(VideoCellRefreshType type, BOOL isRefresh) {
            if (index == kVideoCellDelegate_topRightCornerCommentEvent) {
                if (type == VideoCellRefreshType_Remove && isRefresh) {
                    if (weakSelf.removeCellBlock) {
                        weakSelf.removeCellBlock(weakSelf.indexP,weakSelf.model);
                    }
                }
            }
            else if (index == kVideoCellDelegate_topRightCornerCollectEvent) {
                if (type == VideoCellRefreshType_Collect && isRefresh) {
                    [weakSelf refreshCollectView];
                }
            }
        }];
    }
}


#pragma mark -
#pragma mark UI
- (void)hiddenHeadView
{
    self.topGrayBgView.hidden = YES;
    [self.playerBgView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
    }];
}


- (void)hiddenCellBtnsView
{
    self.footBtnsBgView.hidden = YES;
    [self.descLabel remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.playerBgView.mas_bottom).offset(13);
        make.leading.mas_equalTo(10);
        make.trailing.mas_equalTo(-(kStarBgViewWidth + 20));
    }];
    
    [self.moreImgView remakeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(-10);
        make.top.equalTo(self.starBgView.mas_bottom).offset(18);
        make.size.mas_equalTo(CGSizeMake(13, 3));
    }];
    
    [self.moreBtn remakeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(0);
        make.top.equalTo(self.starBgView.mas_bottom);
        make.size.mas_equalTo(CGSizeMake(60, 40));
        make.bottom.equalTo(self.footGrayView.mas_top);
    }];
}

- (void)hidddenCouponAndGroupsView
{
    self.couponsAndGrouponBgView.hidden = YES;
    self.couponsBgView.hidden = YES;
    self.groupsBgView.hidden = YES;
    
    // 简述
    [self.descLabel updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.footGrayView.mas_top).offset(-13);//没有底部抢券,拼团时,调节此参数
    }];
    
}

- (void)restoreCouponAndGroupView
{
    self.couponsAndGrouponBgView.hidden = NO;
    self.couponsAndGrouponMidLine.hidden = NO;
    self.couponsBgView.hidden = NO;
    self.groupsBgView.hidden = NO;
    GET_SCREEN_WIDTH(sWidth);
    GET_SCREEN_SCALE(scale);
    
    //优惠券
    [self.couponsBgView updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(sWidth/2);
    }];
    
    //拼团底图
    [self.groupsBgView updateConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(sWidth/2);
        make.width.mas_equalTo(sWidth/2);
    }];

    //简述
    [self.descLabel updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.footGrayView.mas_top).offset(-(kCouponAngGrouponViewHeight*scale + 13));//没有底部抢券,拼团时,调节此参数
    }];

}

//只有团购
- (void)onlyHaveGroup
{
    self.couponsAndGrouponBgView.hidden = NO;
    self.couponsAndGrouponMidLine.hidden = YES;
    self.groupsBgView.hidden = NO;
    self.couponsBgView.hidden = YES;
    
    GET_SCREEN_SCALE(scale);
    GET_SCREEN_WIDTH(sWidth);
    [self.groupsBgView updateConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(0);
        make.width.mas_equalTo(sWidth);
    }];
    
    //简述
    [self.descLabel updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.footGrayView.mas_top).offset(-(kCouponAngGrouponViewHeight*scale + 13));//没有底部抢券,拼团时,调节此参数
    }];
    
}

//只有优惠券
- (void)onlyHaveCoupon
{
    self.couponsAndGrouponBgView.hidden = NO;
    self.couponsAndGrouponMidLine.hidden = YES;
    self.couponsBgView.hidden = NO;
    self.groupsBgView.hidden = YES;
    
    GET_SCREEN_SCALE(scale);
    GET_SCREEN_WIDTH(sWidth);
    //简述
    [self.descLabel updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.footGrayView.mas_top).offset(-(kCouponAngGrouponViewHeight*scale + 13));//没有底部抢券,拼团时,调节此参数
    }];
    
    
    [self.couponsBgView updateConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(sWidth);
    }];
}

#pragma mark - 
#pragma mark 最初的布局 约束设定======================
- (void)initUI
{
    GET_SCREEN_SCALE(scale)
    GET_SCREEN_WIDTH(sWidth)
    //上部灰色底框
   [self.topGrayBgView mas_makeConstraints:^(MASConstraintMaker *make) {
       make.leading.mas_equalTo(0);
       make.top.mas_equalTo(0);
       make.trailing.mas_equalTo(0);
       make.height.mas_equalTo(kTopGrayViewHegith*scale);
   }];
    
    //头像
    [self.userIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(12.5);
        make.top.mas_equalTo(7.5);
        make.bottom.mas_equalTo(-7.5);
        make.width.equalTo(self.userIcon.height);
    }];
    
    //用户名
    [self.userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.userIcon.mas_trailing).offset(8);
        make.trailing.lessThanOrEqualTo(self.viewsIcon.mas_leading).offset(-20);
        make.top.mas_equalTo(12);
    }];
    
    //时间
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.userNameLabel);
        make.top.equalTo(self.userNameLabel.mas_bottom);
    }];
    
    //播放次数
    [self.viewsCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(-10.5);
        make.centerY .equalTo(self.topGrayBgView);
    }];
    
    //播放icon
    [self.viewsIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(self.viewsCountLabel.mas_leading).offset(-5);
        make.centerY.equalTo(self.topGrayBgView);
        make.size.mas_equalTo(CGSizeMake(17, 11.5));
    }];
    
    //播放器 父View
    [self.playerBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(kTopGrayViewHegith*scale);
        make.leading.mas_equalTo(0);
        make.width.mas_equalTo(sWidth);
        make.height.mas_equalTo(sWidth).priority(999);
    }];
    
    //右上角图片
    [self.collectOrEditImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(self.playerBgView.mas_trailing).offset(-10);
        make.top.equalTo(self.playerBgView).offset(10);
//        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
    
    //右上角按钮
    [self.collectOrEditBtn  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.playerBgView);
        make.trailing.equalTo(self.playerBgView);
        make.size.mas_equalTo(CGSizeMake(80, 60));
    }];
    
    //视频封面
    [self.videoCoverImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(0);
        make.trailing.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    
    //按钮底图 ******不显示此按钮的话,直接隐藏 同时修改deslabel 的top的约束为13
    [self.footBtnsBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.playerBgView.mas_bottom).offset(13);
        make.leading.mas_equalTo(10);
        make.trailing.mas_equalTo(-(kStarBgViewWidth + 20));
        make.height.mas_equalTo(kCellBtnsViewHeight);
    }];
    
    //赞 图
    [self.zanImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(0);
        make.centerY.equalTo(self.footBtnsBgView);
    }];
    
    //赞 数量
    [self.zanCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.leading.equalTo(self.zanImg.mas_trailing).offset(5);
    }];
    
    //赞 按钮
    [self.zanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.leading.equalTo(self.zanImg);
        make.trailing.equalTo(self.zanCountLabel);
        make.bottom.mas_equalTo(0);
    }];
    
    //收藏,关注 图
    [self.collectImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.zanCountLabel.mas_trailing).offset(20*scale);
        make.centerY.equalTo(self.footBtnsBgView);
    }];
    
    //收藏 关注 数量
    [self.collectCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.leading.equalTo(self.collectImg.mas_trailing).offset(5);
    }];
    
    //收藏 关注 按钮
    [self.collectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.leading.equalTo(self.collectImg);
        make.trailing.equalTo(self.collectCountLabel);
        make.bottom.mas_equalTo(0);
    }];
    
    
    //信息 评论 图
    [self.msgImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.collectCountLabel.mas_trailing).offset(20*scale);
        make.centerY.equalTo(self.footBtnsBgView);
    }];
    
    //信息 评论 数量
    [self.msgCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.leading.equalTo(self.msgImg.mas_trailing).offset(5);
    }];
    
    //信息 评论 按钮
    [self.msgBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.leading.equalTo(self.msgImg);
        make.trailing.equalTo(self.msgCountLabel);
        make.bottom.mas_equalTo(0);
    }];
    
    
    //分享 图
    [self.shareImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.msgCountLabel.mas_trailing).offset(20*scale);
        make.centerY.equalTo(self.footBtnsBgView);
    }];
    
    //分享 数量
    [self.shareCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.leading.equalTo(self.shareImg.mas_trailing).offset(5);
    }];
    
    //分享 按钮
    [self.shareBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.leading.equalTo(self.shareImg);
        make.trailing.equalTo(self.shareCountLabel);
        make.bottom.mas_equalTo(0);
    }];

    //评星底图
    [self.starBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.footBtnsBgView);
        make.trailing.mas_equalTo(-10);
        make.size.mas_equalTo(CGSizeMake(kStarBgViewWidth, kStarBgViewHeiht));
    }];
    
    // 评星
    [self.starBgView addSubview:self.starRatingView];
    [self.starRatingView makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.starBgView);
    }];

    
    //简述
    [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(10);
        make.top.equalTo(self.playerBgView.mas_bottom).offset(13 + kCellBtnsViewHeight + 13);//没有按钮视图的时候更新此约束
        make.trailing.mas_equalTo(-(kStarBgViewWidth + 20));
        make.bottom.equalTo(self.footGrayView.mas_top).offset(-(kCouponAngGrouponViewHeight*scale + 15));//没有底部抢券,拼团时,调节此参数
    }];
    
    //更多 图片
    [self.moreImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(-10);
        make.centerY.equalTo(self.descLabel);
        
    }];
    
    //更多 按钮
    [self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(0);
        make.top.equalTo(self.moreImgView).offset(-16);
        make.size.mas_equalTo(CGSizeMake(60, 40));
    }];
    
    //优惠券 团购底图**** 如果没有.则直接隐藏掉. 调节desclabel的bottom约束
    [self.couponsAndGrouponBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_offset(0);
        make.trailing.mas_offset(0);
        make.bottom.mas_equalTo(-10);
        make.height.mas_equalTo(kCouponAngGrouponViewHeight*scale);
    }];
    
    //横线
    [self.couponsAndGrouponTopLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.trailing.mas_equalTo(0);
        make.height.mas_equalTo(0.5);
    }];
    
    //竖线
    [self.couponsAndGrouponMidLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.couponsAndGrouponBgView);
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.width.mas_equalTo(.5);
    }];
    
    //优惠券
    [self.couponsBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.width.mas_equalTo(sWidth/2);
        make.height.mas_equalTo(kCouponAngGrouponViewHeight*scale);
    }];
    
    //优惠券名称
    [self.couponsTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.couponsBgView).offset(self.couponsTextHeight/2 - 5);
        if ([[LZLanguageManager shareInstance] getLanguageType] == LanguageType_Ar) {
            make.centerX.equalTo(self.couponsBgView).offset(-15.5);
        }else{
            make.centerX.equalTo(self.couponsBgView).offset(15.5);
        }
        
    }];
    
    //优惠券icon
    [self.couponsIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.couponsBgView);
        make.trailing.equalTo(self.couponsTitleLabel.mas_leading).offset(-10);
    }];
    
    //优惠券剩余数量
    [self.couponsCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.couponsTitleLabel.mas_bottom).offset(3);
        make.leading.equalTo(self.couponsTitleLabel);
    }];
    
    //拼团底图
    [self.groupsBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(sWidth/2);
        make.height.mas_equalTo(kCouponAngGrouponViewHeight*scale);
        make.width.mas_equalTo(sWidth/2);
        make.top.mas_equalTo(0);
    }];
    
    //拼团名称
    [self.groupsTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.groupsBgView).offset(self.couponsTextHeight/2 - 5);
        if ([[LZLanguageManager shareInstance] getLanguageType] == LanguageType_Ar) {
            make.centerX.equalTo(self.groupsBgView).offset(-15);
        }else{
            make.centerX.equalTo(self.groupsBgView).offset(15);
        }
    }];
    
    //拼团icon
    [self.groupsIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.couponsBgView);
        make.trailing.equalTo(self.groupsTitleLabel.mas_leading).offset(-10);
    }];
    
    //拼团倒计时
    [self.groupsCountdownLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.groupsTitleLabel.mas_bottom).offset(3);
        make.leading.equalTo(self.groupsTitleLabel);
    }];
    
    //底部灰色的条
    [self.footGrayView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(0);
        make.trailing.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(10);
    }];
    
}

#pragma mark - 下面是初始化 初始化控件==============================
#pragma mark 控件初始化

- (UIView *)topGrayBgView
{
    if (!_topGrayBgView) {
        _topGrayBgView = [[UIView alloc] init];
        _topGrayBgView.backgroundColor = UIColorFromRGB(0xffffff, 1);
    }
    
    return _topGrayBgView;
}

- (UIImageView *)userIcon
{
    if (!_userIcon) {
        _userIcon = [[UIImageView alloc] init];
        _userIcon.image = [UIImage imageNamed:@"未设置头像"];
    }
    
    return _userIcon;
}

- (UILabel *)userNameLabel
{
    GET_SCREEN_SCALE(scale)
    if (!_userNameLabel) {
        _userNameLabel = [[UILabel alloc] init];
        _userNameLabel.backgroundColor = [UIColor clearColor];
        _userNameLabel.textColor = UIColorFromRGB(0x333333, 1);
        _userNameLabel.font = [UIFont fontWithName:@"ArialMT" size:13*scale];
        
    }
    return  _userNameLabel;
}

- (UILabel *)timeLabel
{
    GET_SCREEN_SCALE(scale)
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] init];
        _timeLabel.backgroundColor = [UIColor clearColor];
        _timeLabel.textColor = UIColorFromRGB(0x999999, 1);
        _timeLabel.font = [UIFont fontWithName:@"ArialMT" size:11*scale];
    }
    
    return _timeLabel;
}

- (UIImageView *)viewsIcon
{
    if (!_viewsIcon) {
        _viewsIcon = [[UIImageView alloc] init];
        _viewsIcon.image = [UIImage imageNamed:@"video_views"];
        [_viewsIcon setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
        [_viewsIcon setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
    }
    return _viewsIcon;
}

- (UILabel *)viewsCountLabel
{
    GET_SCREEN_SCALE(scale)
    if (!_viewsCountLabel) {
        _viewsCountLabel = [[UILabel alloc] init];
        _viewsCountLabel.backgroundColor = [UIColor clearColor];
        _viewsCountLabel.textColor = UIColorFromRGB(0x999999, 1);
        _viewsCountLabel.font = [UIFont fontWithName:@"ArialMT" size:13*scale];
        [_viewsCountLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
        
    }
    return  _viewsCountLabel;
}

- (UIImageView *)videoCoverImg
{
    if (!_videoCoverImg) {
        _videoCoverImg = [[UIImageView alloc] init];
        _videoCoverImg.userInteractionEnabled = YES;
        _videoCoverImg.backgroundColor = [UIColor clearColor];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(playAction)];
        [_videoCoverImg addGestureRecognizer:tap];
    }
    
    return _videoCoverImg;
}

- (UIView *)playerBgView
{
    if (!_playerBgView) {
        _playerBgView = [[UIView alloc] init];
        _playerBgView.backgroundColor = [UIColor blackColor];
    }
    return _playerBgView;
}

- (UIView *)couponsAndGrouponBgView
{
    if (!_couponsAndGrouponBgView) {
        _couponsAndGrouponBgView = [[UIView alloc] init];
        _couponsAndGrouponBgView.backgroundColor = [UIColor whiteColor];
        
        extern NSInteger couponAndGrouponBgViewTag;
        _couponsAndGrouponBgView.tag = couponAndGrouponBgViewTag;
    }
    
    return _couponsAndGrouponBgView;
}

- (UIView *)couponsAndGrouponTopLine
{
    if (!_couponsAndGrouponTopLine) {
        _couponsAndGrouponTopLine = [[UIView alloc] init];
        _couponsAndGrouponTopLine.backgroundColor = UIColorFromRGB(0xcccccc, 1);
    }
    
    return _couponsAndGrouponTopLine;
}

- (UIView *)couponsAndGrouponMidLine
{
    if (!_couponsAndGrouponMidLine) {
        _couponsAndGrouponMidLine = [[UIView alloc] init];
        _couponsAndGrouponMidLine.backgroundColor = UIColorFromRGB(0xcccccc, 1);
    }
    return _couponsAndGrouponMidLine;
}

- (UIView *)couponsBgView
{
    if (!_couponsBgView) {
        _couponsBgView = [[UIView alloc] init];
        _couponsBgView.backgroundColor = [UIColor clearColor];
        _couponsBgView.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(couponsDetailAction)];
        [_couponsBgView addGestureRecognizer:tap];
        
        extern NSInteger couponBgViewTag;
        _couponsBgView.tag = couponBgViewTag;
    }
    return _couponsBgView;
}

- (UIImageView *)couponsIcon
{
    if (!_couponsIcon) {
        _couponsIcon = [[UIImageView alloc] init];
        _couponsIcon.image = [UIImage imageNamed:@"home_coupons_icon"];
    }
    
    return _couponsIcon;
}

- (UILabel *)couponsTitleLabel
{
    GET_SCREEN_SCALE(scale)
    if (!_couponsTitleLabel) {
        _couponsTitleLabel = [[UILabel alloc] init];
        _couponsTitleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:12*scale];
        _couponsTitleLabel.textColor = UIColorFromRGB(0xff7a21, 1);
        _couponsTitleLabel.textAlignment = NSTextAlignmentCenter;
    }
    
    return _couponsTitleLabel;
}

- (UILabel *)couponsCountLabel
{
    GET_SCREEN_SCALE(scale)
    if (!_couponsCountLabel) {
        _couponsCountLabel = [[UILabel alloc] init];
        _couponsCountLabel.font = [UIFont fontWithName:@"ArialMT" size:12*scale];
        _couponsCountLabel.textColor = UIColorFromRGB(0xff7a21, 1);
        _couponsCountLabel.textAlignment = NSTextAlignmentCenter;

    }
    
    return _couponsCountLabel;
}


- (UIView *)groupsBgView
{
    if (!_groupsBgView) {
        _groupsBgView = [[UIView alloc] init];
        _groupsBgView.backgroundColor = [UIColor clearColor];
        _groupsBgView.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(groupsDetailAction)];
        [_groupsBgView addGestureRecognizer:tap];
        
        extern NSInteger grouponBgViewTag;
        _groupsBgView.tag = grouponBgViewTag;
    }
    return _groupsBgView;
}

- (UIImageView *)groupsIcon
{
    if (!_groupsIcon) {
        _groupsIcon = [[UIImageView alloc] init];
        _groupsIcon.image = [UIImage imageNamed:@"home_groupons_icon"];
    }
    return _groupsIcon;
}

- (UILabel *)groupsTitleLabel
{
    GET_SCREEN_SCALE(scale)
    if (!_groupsTitleLabel) {
        _groupsTitleLabel = [[UILabel alloc] init];
        _groupsTitleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:12*scale];
        _groupsTitleLabel.textColor = UIColorFromRGB(0xff7a21, 1);
        _groupsTitleLabel.textAlignment = NSTextAlignmentCenter;
    }
    
    return _groupsTitleLabel;
}

- (UILabel *)groupsCountdownLabel
{
    GET_SCREEN_SCALE(scale)
    if (!_groupsCountdownLabel) {
        _groupsCountdownLabel = [[UILabel alloc] init];
        _groupsCountdownLabel.font = [UIFont fontWithName:@"ArialMT" size:12*scale];
        _groupsCountdownLabel.textColor = UIColorFromRGB(0xff7a21, 1);
        _groupsCountdownLabel.textAlignment = NSTextAlignmentCenter;
        
    }
    
    return _groupsCountdownLabel;
}


- (GiftListLabel *)descLabel
{
    GET_SCREEN_SCALE(scale)
    if (!_descLabel) {
        _descLabel = [[GiftListLabel alloc] init];
        _descLabel.numberOfLines = 2;
        _descLabel.textColor = UIColorFromRGB(0x666666, 1);
        _descLabel.font = [UIFont fontWithName:@"ArialMT" size:15*scale];
        _descLabel.textAlignment = NSTextAlignmentLeft;
        [_descLabel setVerticalAlignment:VerticalAlignmentTop];
    }
    
    return _descLabel;
}

- (UIView *)starBgView
{
    if (!_starBgView) {
        _starBgView = [[UIView alloc] init];
        _starBgView.backgroundColor = [UIColor clearColor];
        
    }
    return _starBgView;
}

- (UIView *)footBtnsBgView
{
    if (!_footBtnsBgView) {
        _footBtnsBgView = [[UIView alloc] init];
        _footBtnsBgView.backgroundColor = [UIColor clearColor];
        _footBtnsBgView.userInteractionEnabled = YES;
        
    }
    
    return _footBtnsBgView;
}

- (UIImageView *)moreImgView
{
    if (!_moreImgView) {
        _moreImgView = [[UIImageView alloc] init];
        _moreImgView.backgroundColor = [UIColor clearColor];
        _moreImgView.image = [UIImage imageNamed:@"home_video_more"];
    }
    
    return _moreImgView;
}

- (UIButton *)moreBtn
{
    if (!_moreBtn) {
        _moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _moreBtn.backgroundColor = [UIColor clearColor];
        [_moreBtn addTarget:self action:@selector(showMoreAction) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _moreBtn;
}

- (UIImageView *)zanImg
{
    if (!_zanImg) {
        _zanImg = [[UIImageView alloc] init];
        _zanImg.image = [UIImage imageNamed:@"首页_点赞_未点赞"];
        _zanImg.highlightedImage = [UIImage imageNamed:@"首页_点赞_已点赞"];
        _zanImg.userInteractionEnabled = YES;
    }
    return _zanImg;
}

- (UILabel *)zanCountLabel
{
    GET_SCREEN_SCALE(scale)
    if (!_zanCountLabel) {
        _zanCountLabel = [[UILabel alloc] init];
        _zanCountLabel.textColor = UIColorFromRGB(0x999999, 1);
        _zanCountLabel.font = [UIFont fontWithName:@"ArialMT" size:15*scale];
        _zanCountLabel.userInteractionEnabled = YES;
    }
    
    return _zanCountLabel;
    
}

- (UIButton *)zanBtn
{
    if (!_zanBtn) {
        _zanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _zanBtn.backgroundColor = [UIColor clearColor];
        [_zanBtn addTarget:self action:@selector(zanBtnAction) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _zanBtn;
}

- (UIImageView *)collectImg
{
    if (!_collectImg) {
        _collectImg = [[UIImageView alloc] init];
        _collectImg.image = [UIImage imageNamed:@"关注"];
        _collectImg.highlightedImage = [UIImage imageNamed:@"首页_关注_已收藏"];
        _collectImg.userInteractionEnabled = YES;
    }
    return _collectImg;
}

- (UILabel *)collectCountLabel
{
    GET_SCREEN_SCALE(scale)
    if (!_collectCountLabel) {
        _collectCountLabel = [[UILabel alloc] init];
        _collectCountLabel.textColor = UIColorFromRGB(0x999999, 1);
        _collectCountLabel.font = [UIFont fontWithName:@"ArialMT" size:15*scale];
        _collectCountLabel.userInteractionEnabled = YES;
    }
    
    return _collectCountLabel;
    
}

- (UIButton *)collectBtn
{
    if (!_collectBtn) {
        _collectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _collectBtn.backgroundColor = [UIColor clearColor];
        [_collectBtn addTarget:self action:@selector(collectBtnAction) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _collectBtn;
}


- (UIImageView *)msgImg
{
    if (!_msgImg) {
        _msgImg = [[UIImageView alloc] init];
        _msgImg.image = [UIImage imageNamed:@"首页_评价"];
        _msgImg.userInteractionEnabled = YES;
    }
    return _msgImg;
}

- (UILabel *)msgCountLabel
{
    GET_SCREEN_SCALE(scale)
    if (!_msgCountLabel) {
        _msgCountLabel = [[UILabel alloc] init];
        _msgCountLabel.textColor = UIColorFromRGB(0x999999, 1);
        _msgCountLabel.font = [UIFont fontWithName:@"ArialMT" size:15*scale];
        _msgCountLabel.userInteractionEnabled = YES;
    }
    
    return _msgCountLabel;
    
}

- (UIButton *)msgBtn
{
    if (!_msgBtn) {
        _msgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _msgBtn.backgroundColor = [UIColor clearColor];
        [_msgBtn addTarget:self action:@selector(msgBtnAction) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _msgBtn;
}


- (UIImageView *)shareImg
{
    if (!_shareImg) {
        _shareImg = [[UIImageView alloc] init];
        _shareImg.image = [UIImage imageNamed:@"首页_分享"];
        _shareImg.userInteractionEnabled = YES;
    }
    return _shareImg;
}

- (UILabel *)shareCountLabel
{
    GET_SCREEN_SCALE(scale)
    if (!_shareCountLabel) {
        _shareCountLabel = [[UILabel alloc] init];
        _shareCountLabel.textColor = UIColorFromRGB(0x999999, 1);
        _shareCountLabel.font = [UIFont fontWithName:@"ArialMT" size:15*scale];
        _shareCountLabel.userInteractionEnabled = YES;
    }
    
    return _shareCountLabel;
    
}

- (UIButton *)shareBtn
{
    if (!_shareBtn) {
        _shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _shareBtn.backgroundColor = [UIColor clearColor];
        [_shareBtn addTarget:self action:@selector(shareBtnAction) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _shareBtn;
}

- (UIImageView *)collectOrEditImgView
{
    if (!_collectOrEditImgView) {
        _collectOrEditImgView = [[UIImageView alloc] init];
        _collectOrEditImgView.hidden = YES;
    }
    
    return _collectOrEditImgView;
}

- (UIButton *)collectOrEditBtn
{
    if (!_collectOrEditBtn) {
        _collectOrEditBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _collectOrEditBtn.backgroundColor = [UIColor clearColor];
        _collectOrEditBtn.hidden = YES;
        [_collectOrEditBtn addTarget:self action:@selector(collectOrEditBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _collectOrEditBtn;
}


- (HCSStarRatingView *)starRatingView
{
    if (!_starRatingView) {
        _starRatingView = [[HCSStarRatingView alloc] initWithFrame:CGRectZero];
        _starRatingView.maximumValue = 5;
        _starRatingView.minimumValue = 0;
        _starRatingView.spacing = 2.5;
        _starRatingView.allowsHalfStars = YES;
        _starRatingView.accurateHalfStars = YES;
        _starRatingView.tintColor = UIColorFromRGB(0xF08F4D, 1);
        _starRatingView.userInteractionEnabled = NO;
    }
    
    return _starRatingView;
}

- (UIView *)footGrayView
{
    if (!_footGrayView) {
        _footGrayView = [[UIView alloc] init];
        _footGrayView.backgroundColor = UIColorFromRGB(0xEEEEEE, 1);
    }
    
    return _footGrayView;
}
@end
